import config from "@/config"

const roleList = 
    {  
        code:200,
        data:{token:"SCUI.Administrator.Auth",
        userInfo:{userId:"1",userName:"Administrator",dashboard:"0",
        role:["SA","admin","Auditor"]}},
        message:""
    }

const userlist = [
    {  
        password:"21232f297a57a5a743894a0e4a801fc3",
        username:"admin"
    },
    {  
        password:"21232f297a57a5a743894a0e4a801fc3",
        username:"user"
    }
]

const mock =[{
    url:`${config.API_URL}/token`,
    method:'post',
    timeout,
    response: ({ body }) => {
        const data = body
        let hasUser = false
        for (const user of List) {
          if (user.username === data.username && user.password === data.password) {
            hasUser = true
            return {
               data:roleList             
            }
          }
        }
        if (!hasUser) {
          return {
            data: {
              code: 500,
              message: '账号或密码错误'
            }
          }
        }
      }
},
]

export default mock